#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <fstream>
#include <iostream>
#include <armadillo>
#include <iomanip>


using namespace std;
using namespace arma;
//using namespace dlib;



#include "color_BoT_features_def.hpp"
#include "color_BoT_features_impl.hpp"


#include "classification_def.hpp"
#include "classification_impl.hpp"


#include "svm_dlib_def.hpp"
#include "svm_dlib_impl.hpp"




uword ro = 60;
uword co = 80;

//UQ
//const std::string path = "/home/johanna/codes-svn/resized_UCF11_January31/"; 

//Home
//const std::string path =  "/home/johanna/codes-svn/resized_UCF11_January31/";

//UNAL
const std::string path = "/home/johanna/svn/resized_UCF11_January31";

////When I need to save
const std::string  feat_path ="./coBoT_features/";



//const std::string  feat_path = "./coBoT_features_january31_nBins_16/";
//const int nBins = 16;

//const std::string  feat_path = "./coBoT_features_February8_nBins_256/";
//const int nBins = 256;

//const std::string  feat_path = "./coBoT_features_February10_nBins_1024/";
const int nBins = 1024;




const std::string  actionNames = "actionNames.txt";
const std::string  viNames  = "viNames.txt";
const std::string  viList   = "list.txt";
const std::string  feat_gr_List   = "features_group_list.txt"; 
//const std::string  feat_gr_List   = "features_group_list_mini.txt";
const std::string  lgocv = "LOOCV_actions.dat";





void
create_LOOCV_groups();


int
main(int argc, char** argv)
{
  
  //features_UCF11 UCF11_optflow(path, actionNames, viNames, viList, co, ro);
  //UCF11_optflow.start_features();
  
  //features_colBoT feat2(path, actionNames, viNames, viList, co, ro);
  //feat2.start_colBoT(nBins, feat_path);
  
  //create_LOOCV_groups();
  
  
  //Classifier
  //classification classify(feat_gr_List,lgocv, nBins, feat_path );
  //classify.start();
  
}


void
create_LOOCV_groups()
{
  field<mat> loocv (25,2); // Each action has 25 groups
  std::vector<int> x(25);
  std::vector<int> y(25);
  for (uword i = 0; i<25; ++i){
    x.at(i) = i + 1;
  }
  
  for (uword i = 0; i<25; ++i){
    cout << x.at(i) << ", ";
  }
  
  //cout << "?? " << endl;
  
  for (uword j = 0; j<25; ++j){

    loocv(j,0) = j + 1;
    //copy(x.begin(), x.end(), y.begin());
    y = x;
    y.erase(std::remove(y.begin(), y.end(), j+1), y.end());
    rowvec tmp_y = conv_to<rowvec>::from(y);
    //tmp_y.t().print("tmp_y");
    
    loocv(j,1) = tmp_y;
    /*
    for (int k=0; k<24; k++){
      cout << y.at(k) << ", ";HTC One Double Dip Hard Shell Case
    }*/
     
  }
  
  loocv.print("loocv");
  //field<rowvec> LOOCV2 (25,2); // Each action has 25 groups
  loocv.save("LOOCV_actions.dat");
  //SAVE IT.. and you don't need to run it again
}





/*
 c **** *ma*ke_minimum_required(VERSION 2.8)
 project( grassmann_clustering)
 find_package( OpenCV REQUIRED)
 find_package( Armadillo REQUIRED)
 add_executable( run_3actions.exe Three_actions_UCF11.cpp)
 target_link_libraries( run_3actions.exe ${OpenCV_LIBS} -O1 -larmadillo)
 */